{include file='common/head.html'}

<div class="layui-body">
    {if([$list])}
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this" lay-id="t1">产品列表</li>
            <li lay-id="t2">产品新增</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form action="{url./admin/Member/index}" method="get" class="layui-form">
                    <div class="layui-form-item nospace">
                        <div class="layui-input-inline">
                            {$pathinfo}
                            <select name="field" lay-verify="required">
                                <option value="product_name" {if(get('field')=='product_name')}selected="selected" {/if}>产品名</option>

                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword"  value="{$get.keyword}"  placeholder="请输入搜索关键字" class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <button class="layui-btn" lay-submit>搜索</button>
                            <a class="layui-btn layui-btn-primary"  href="{url./admin/Product/index}">清除搜索</a>
                        </div>
                    </div>
                </form>
                <form action="{url./admin/Product/mod}" method="post" id="contentForm" name="contentForm" class="layui-form" onkeydown="if(event.keyCode==13) return false;">
                    <input type="hidden" name="formcheck" value="{$formcheck}" >

                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th><input type="checkbox" class="checkbox" lay-ignore id="checkall" title="全选"></th>
                            <th>编号</th>
                            <th>产品名称</th>
                            <th>产品图片</th>
                            <th>价格</th>
                            <th>状态</th>
                            <th>可购买数量</th>
                            <th>开始奖励天数</th>
                            <th>利润比例</th>
                            <th>添加时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $product(key,value)}
                        <tr>
                            <td>
                                <input type="checkbox" class="checkbox checkitem" lay-ignore name="list[]" value="[value->id]">
                                <input type="hidden" name="listall[]" value="[value->id]">
                            </td>
                            <td>[value->id]</td>
                            <td>[value->product_name]</td>
                            <td><div style="width: 100px;height: 100px;"><img  src="[value->product_pic]" height="100"width="100"></div></td>
                            <td>[value->price]</td>
                            <td>
                                {if($value->status)}
                                <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/0}"><i class='fa fa-toggle-on' title="点击禁用"></i></a>
                                {else}
                                <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/1}"><i class='fa fa-toggle-off' title="点击启用"></i></a>
                                {/if}
                            </td>
                            <td>[value->amount]</td>
                            <td>[value->days]</td>
                            <td>[value->ratio]</td>

                            <td>[value->add_time]</td>
                            <td>
                                {fun=get_btn_del($value->id)}
                                {fun=get_btn_mod($value->id)}
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>


                </form>
                <div class="page">{$pagebar}</div>
            </div>

            <div class="layui-tab-item">
                <form action="{url./admin/Product/add}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}" >

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品标题<span class="layui-text-red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="product_name" required  lay-verify="required"  autocomplete="off"  placeholder="请输入产品标题" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品图片</label>
                        <div class="layui-input-inline">
                            <input type="text" name="product_pic" id="headpic" placeholder="请产品图片"  class="layui-input">
                        </div>
                        <button type="button" class="layui-btn upload" data-des="headpic">
                            <i class="layui-icon">&#xe67c;</i>上传图片
                        </button>
                        <div id="headpic_box" class="pic addedit"></div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">价格</label>
                            <div class="layui-input-inline">
                                <input type="tel" name="price"   lay-verify="required"autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">数量</label>
                            <div class="layui-input-inline">
                                <input type="text" name="amount"  lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">奖励天数</label>
                            <div class="layui-input-inline">
                                <input type="tel" name="days"  autocomplete="off"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">利润比例</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ratio"  autocomplete="off" placeholder="%" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">内容详情</label>
                        <div class="layui-input-block">
                            <script type="text/plain" id="editor_describe" name="describe" style="width:100%;height:240px;"></script>

                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="1" title="启用" checked>
                            <input type="radio" name="status" value="0" title="禁用">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit>立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            {fun=get_btn_back()}
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {/if}


    {if([$mod])}
    <div class="layui-tab layui-tab-brief" lay-filter="tab">
        <ul class="layui-tab-title">
            <li class="layui-this">产品修改</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form action="{url./admin/Product/mod/id/'.[$get.id].'}{$backurl}" method="post" class="layui-form">
                    <input type="hidden" name="formcheck" value="{$formcheck}" >


                    <div class="layui-form-item">
                        <label class="layui-form-label">产品标题<span class="layui-text-red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="product_name" required  value="{$product->product_name}" lay-verify="required"  autocomplete="off"  placeholder="请输入产品标题" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">产品图片</label>
                        <div class="layui-input-inline">
                            <input type="text" name="product_pic" id="headpic" placeholder="请产品图片" value="{$product->product_pic}"  class="layui-input">
                        </div>
                        <button type="button" class="layui-btn upload" data-des="headpic">
                            <i class="layui-icon">&#xe67c;</i>上传图片
                        </button>
                        <div id="headpic_box" class="pic addedit">
                            {if([$product->product_pic])}<dl><dt><img src="{SITE_DIR}{$product->product_pic}" data-url="{$product->product_pic}"></dt><dd>删除</dd></dl>{/if}
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">价格</label>
                            <div class="layui-input-inline">
                                <input type="text" name="price"   value="{$product->price}"   lay-verify="required"autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">数量</label>
                            <div class="layui-input-inline">
                                <input type="text" name="amount"  value="{$product->amount}"   lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">奖励天数</label>
                            <div class="layui-input-inline">
                                <input type="text" name="days" value="{$product->days}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">利润比例</label>
                            <div class="layui-input-inline">
                                <input type="text" name="ratio"   value="{$product->ratio}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">内容详情</label>
                        <div class="layui-input-block">
                            <script type="text/plain" id="editor_describe" name="describe" style="width:100%;height:240px;">{fun=decode_string([$product->describe])}</script>

                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="status" value="1" title="启用" checked>
                            <input type="radio" name="status" value="0" title="禁用">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit>立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            {fun=get_btn_back()}
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
    {/if}
</div>
<script>
    //初始化编辑器
    $(document).ready(function (e) {
        var ue = UE.getEditor('editor_describe',{
            maximumWords:10000
        });
    })
</script>

{include file='common/ueditor.html'}
{include file='common/foot.html'}
